public class Test {
    public ListNode deleteDuplicates (ListNode head) {
        // write code here
        if(head == null) {
            return null;
        }
        if(head.next == null) {
            return head;
        }

        ListNode fast = head.next;
        ListNode slow = head;

        while(fast != null) {
            if(fast.val == slow.val) {
                slow.next = fast.next;
                fast = fast.next;
            }else {
                fast = fast.next;
                slow = slow.next;

            }
        }
        return head;
    }
    public ListNode deleteDuplicates (ListNode head) {
        // write code here
        if(head == null) {
            return null;
        }
        if(head.next == null) {
            return head;
        }

        ListNode fast = head.next;
        ListNode slow = head;

        while(fast != null) {
            if(fast.val == slow.val) {
                slow.next = fast.next;
                fast = fast.next;
            }else {
                fast = fast.next;
                slow = slow.next;

            }
        }
        return head;
    }
}
